import request from '@/utils/request'
import type { Classify } from '@/api/types/classify'

export const list = () => {
  return request<Classify[]>({
    method: 'get',
    url: '/admin/classify/list'
  })
}

export const add = (data: Classify) => {
  return request<boolean>({
    method: 'post',
    url: '/admin/classify',
    data
  })
}

export const deleteByIds = (ids: number[]) => {
  return request<boolean>({
    method: 'delete',
    url: '/admin/classify/' + String(ids)
  })
}

export const getClassifyTree = (hasRoot: number) => {
  return request<[]>({
    method: 'get',
    url: '/admin/classify/tree/' + hasRoot

  })
}

export const getClassify = (id: number | any) => {
  return request<Classify>({
    method: 'get',
    url: '/admin/classify/' + id
  })
}

export const update = (data: Classify) => {
  return request<boolean>({
    method: 'put',
    url: '/admin/classify',
    data
  })
}